Shapes of functions

Functions: building blocks of models

As we begin to construct models, let’s think about the building blocks of mathematical relationships: functions and their shapes.

As a brief review, we will go over the basic function types we will see in this course. Some are trivial, and some are complicated.

Straight lines

The linear function is given by \[ f(x) = ax + b \]

Polynomials

A quadratic function is given by \(f(x) = bx^2 + cx + d\)

A cubic function is given by \(f(x) = ax^3 + bx^2 + cx + d\)

Exponential function

The exponential function is the unique function \(f(x)\) such that \(f'(x)=f(x)\) for all \(x\), \(f(x) = e^{x}\), where \(e\approx 2.7182\ldots\). The exponential function may also be written as \(f(x) = \exp(x)\).

When \(x\) is positive, \(\exp(x)\) grows quickly; as \(x\) becomes more negative, it decays toward zero.

Logarithmic function

The inverse function of \(\exp(\cdot)\) is the natural logarithm \[ f(x) = \log(x) \] That is, if \(x\) is any real number and \(y=\exp(x)\), then \(x = \log(y)\)

Logistic function

Logistic growth happens when initially a quantity grows exponentially but then saturates, or plateaus. \[ f(x) = \frac{e^{ax}}{1+e^{ax}} = \frac{1}{1+e^{-ax}} \]

Informal and formal descriptions

  • Straight: linear
  • Growing: exponential (positive argument)
  • Decaying: exponential (negative argument)
  • Saturated: logistic
  • Oscillating/periodic: sinusoidal

Principles of mechanistic thinking

States of being

Most models we will see in this class express their dynamics in terms of states of being.

Examples: HIV+, in treatment, using drugs, etc.

For us, a state might be an attribute of an individual person/agent, or the proportion of a population having that attribute.

The dynamics of a model describes transitions between states over time.

Modeling with diagrams

A compartmental diagram is a conceptual tool that can be helpful for visualizing model structure and dynamics.

  • Way to visualize the assumptions that we will later be writing into equations
  • Allows efficient understanding and manipulation of these assumptions
  • Easily communicated to audiences with limited mathematical training

Example: an individualistic compartmental model

Consider a model of health for a single individual, who can be either healthy (\(H\)) or sick (\(S\)). The individual may transition between these states, possibly with different rates.

Suppose \(H=1\) means that the individual is healthy, and \(S=1\) means the individual is sick. Because these are the only possibilities, \(H=1-S\). We say that \(H\) and \(S\) are discrete indicator variables for the individual whose state we are modeling.

Example: a population-level compartmental model

Consider a model of health for a population of individuals, each of whom can be either healthy (\(H\)) or sick (\(S\)). The individuals in the population may transition between these states, possibly with different rates.

Let \(H\) be the proportion of individuals who are healthy, and \(S\) the proportion who are sick. Because these population proportions must sum to one, \(H+S=1\).

The compartments are the same, but the level of focus of the model is different: individual versus population. Now \(H\) and \(S\) are continuous instead of discrete.

Discrete time models

Discrete-time models index compartments by chunks of time: seconds, minutes, days, months, quarters, trimesters, years, follow-up visits, etc. Example: At time points \(t=1,2,3,\ldots\), an individual in \(H\) transitions to \(S\) with probability \(p\), and stays in \(H\) with probability \(1-p\). Likewise, an individual in \(S\) transitions to \(H\) with probability \(q\). This is a discrete-time stochastic model for the individual health state.

Continuous time models

Continuous-time models index compartments continuously in arbitrarily small time units. Transitions \(H\to S\) happen in continuous time with rate \(\lambda\), and \(S\to H\) with rate \(\mu\).

Deterministic and stochastic models

Deterministic models always have the same output, given the same initial conditions.

Stochastic models incorporate chance, or randomness, and may have different output, given the same initial conditions.

Whether stochasticity/randomness matters depends on what you seek to model, and what questions you seek to answer. If there is heterogeneity in the process you want to model, representing this with randomness in individual attributes may make sense.

Types of dynamic models

Modeling with rates

One way to construct the dynamics of a compartmental model is to specify the rates of transition between model compartments.

What is a rate? Recall that the derivative of a differentiable function \(f(t)\) at \(t\) is defined as

\[ f'(t) = \lim_{h\to 0} \frac{f(t+h) - f(t)}{h} \]

Why characterize a process by its rates of change?

It is often easier to think about the dynamics of a process in terms of its rates of change. It is very common that the solution to a system of differential equations is impossible to write down analytically, but very easy to characterize in terms of its rates of change.

So, from a practical perspective, we can often just write the system in terms of its rates of change, and then use a computer to find the “solution” for the dynamics of the system.

Dynamics via rates of change

How does compartment occupancy change?

  • Constant change: \(X(t)\) changes at rate \(\lambda\)
  • Proportional change: \(X(t)\) changes at rate \(\lambda X(t)\)
  • Mass action: \(X(t)\) changes at rate \(\lambda X(t) Y(t)\)
  • Saturation: \(X(t)\) changes at rate \(\lambda X(t)(1 - X(t)/K)\)

Transition rates in an individual-level model

The model is parameterized by its transition rates \(\lambda\) and \(\mu\). What does this mean? Let’s think about it in terms of probabilities:

Suppose the current state at time \(t\) is \(H\), so \(H(t)=1\). In a small time \(dt\), the probability of transitioning to \(S\) by \(t+dt\) is \(\lambda \times dt\).

Likewise if the current state at \(t\) is \(S\), so \(S(t)=1\), the probability of transitioning to \(H\) is \(\mu dt\).

Transition rates in a population-level model

This implies that the value of \(H\) at \(t+dt\) is approximately:

\[ \begin{aligned} H(t+dt) &\approx \Pr(\text{stay in }H) H(t) + \Pr(\text{move from $S$ to }H) S(t) \\ &= (1-\lambda dt) H(t) + \mu dt S(t) \\ H(t+dt) - H(t) &= -\lambda dt H(t) + \mu dt S(t) \end{aligned} \]

Dividing by \(dt\) and taking the limit \(dt \to 0\), we obtain the differential equation

\[ \frac{dH}{dt} = -\lambda H(t) + \mu (1-H(t)) \]

How do we interpret this?

We obtain the differential equation system, which has a population interpretation:

\[ \frac{dH}{dt} = -\lambda H(t) + \mu S(t) \] \[ \frac{dS}{dt} = -\mu S(t) + \lambda H(t) \]

This is the rate of change of the population proportion that is healthy: in a small increment of time \(dt\), a fraction \(\lambda dt\) become sick. However, a fraction \(\mu dt\) of sick people become healthy.

The big picture

Mechanistic models come with stories connecting physical interactions in real life with the model specification. Make sure your story makes sense.

  • Think about what you want to know.
  • Think about states/compartments/types. What do you need?
  • Balance realism and parsimony
  • Get the dynamics right.
  • Use prior knowledge. Ask experts.
  • Generate output from the model. Does output look realistic?

References